package com.wms.utils;

import com.wms.model.PageBean;
import com.wms.result.ResultMap;
import com.wms.result.ResultTab;

import java.util.List;
import java.util.Map;

/**
 * @author This
 * @version 1.0
 * @className CommonUtils
 * @description 通用工具类
 * @date 2019/8/5 11:06
 */
public class CommonUtils {
    /**
     * 判断当前页是否为 0
     *
     * @param page
     * @param limit
     * @return
     */
    public static boolean hasPage(Integer page, Integer limit) {
        if (page == 0 || limit == 0) {
            return false;
        }
        return true;
    }

    public static ResultTab failResult() {
        return new ResultTab(1, "请求错误");
    }

    public static boolean isEmpty(List list) {
        return list == null || list.size() < 1;
    }

    public static <T> ResultTab responseRst(PageBean<T> pb) {
        List<T> rows = pb.getRows();
        int total = pb.getTotal();
        return new ResultTab(0, rows, total);
    }
}
